
#include "UnitSpawn.h"

//
// Constructor
//

UnitSpawn::UnitSpawn()
{
}

//
// SetWaveUnit
//

void UnitSpawn::SetWaveUnit(int wave, int unit, int number)
{
	// Check to see if we need to increase size of array
	if(wave >= (int)waves.size())
		if(number == 0) return;
		else waves.push_back(vector<int>(14));

	// Set the value
	waves[wave][unit] = number;

	// Check to see if we need to decrease the size of the array
	if(number == 0 && wave == (int)waves.size()-1 && !WaveHasUnits(wave))
		waves.resize(waves.size()-1);
}

//
// WaveHasUnits
//

bool UnitSpawn::WaveHasUnits(int wave)
{
	if(wave < (int)waves.size())
		for(int i = 0; i < 14; i++)
			if(waves[wave][i] != 0)
				return true;
	return false;
}
